﻿using ACM.MES.工序;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;

namespace ACM.MES
{
    public class MESDataSeedContributor : IDataSeedContributor, ITransientDependency
    {
        private readonly IRepository<Operation, Guid> _operationRepository;
        private readonly OperationManager _operationManager;
        public MESDataSeedContributor(IRepository<Operation, Guid> operationRepository, OperationManager operationManager)
        {
            _operationRepository = operationRepository;
            _operationManager = operationManager;
        }
        public async Task SeedAsync(DataSeedContext context)
        {
            if (await _operationRepository.GetCountAsync() <= 0)
            {
                await _operationRepository.InsertAsync(
                   await _operationManager.CreateAsync("1","清洗",""),
                    autoSave: true
                );

                await _operationRepository.InsertAsync(
                   await _operationManager.CreateAsync("2", "焊接", ""),
                   autoSave: true);
            }
        }
    }
}
